{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Teacher Forcing vs Scheduled Sampling vs Normal Mode"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are 3 ways of training:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Normal mode\n",
    "\n",
    "This mode predicts the next token based on the sentence the model is generating. The benefit of this method is that it knows what to say even if the sentence being generated is rubbish. (Which can't be said for models trained for teacher-forcing)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Teacher forcing\n",
    "\n",
    "This mode predicts the next token based on the correct input. The benefit of this method is that 1. it is trained on the correct labels (normal mode's label is generated by itself, not necessarily accurate always), and 2. it tends to prevent gradient explosion (especially in the case of RNN)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scheduled sampling\n",
    "\n",
    "If you find the above two ways too extreme, this is a compromise. It sometimes uses normal mode (the half-finished sentence the model is generating), and sometimes uses teacher-forcing (using the correct sentence to predict the next token)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
